﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Book.aspx.cs" Inherits="FL.WebUI.ExtendPage.template.desktop.Book" %>
<%@ Import Namespace="System.Data" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
<script src="../../../SFramework/jquery-1.6.2.min.js"></script>
    <style>
        .tree {
            margin: 0px 0px 0px 10px;
            padding: 0px;
            list-style: none;
            font-size: 16px;
            font-family: '微软雅黑';
        }

        .tree1 {
            cursor: pointer;
        }


        .tree li {
            cursor: pointer;
            line-height: 20px;
        }

        .tree3 a {
            text-decoration: none;
            display: block;
        }

        .tree3 div {
            overflow: hidden;
        }

        .tree ul {
            list-style: none;
            margin: 0px;
            display: none;
            padding: 0px;
        }

        .tree .tree2 {
            padding-left: 16px;
            font-size: 14px;
        }

        .tree .tree3 {
            font-size: 12px;
            display: none;
            padding-left: 10px;
        }

        .tree3 img {
            float: left;
            margin-top: 2px;
        }
    </style>
    <script type="text/javascript">

        $().ready(function () {

            $(".tree1").click(function () {
                if ($(this).next().attr("hide") == "0") {
                    $(this).next().show();
                    $(this).next().attr("hide", "1");
                } else {
                    $(this).next().hide();
                    $(this).next().attr("hide", "0");
                }
            });
            $(".tree2 li").click(function () {
                if ($(this).next().attr("hide") == "0") {
                    $(this).next().show();
                    $(this).next().attr("hide", "1");
                } else {
                    $(this).next().hide();
                    $(this).next().attr("hide", "0");
                }
            });
        });
    </script>
</head>
<body>
    <div class="tree">
        <%
//        "select t1.id,t1.long_name long_name, t1.parent_id parent_id,e.name name,h.phone phone,h.office_tel office_tel,h.email email,h.short_num short_num,h.qq qq,h.fax fax,
//(case when t2.id is null then 0 else 1 end) as p
// from  t_base_department t1 left join t_base_department t2 on t1.parent_id=t2.id
// left join t_base_employee e on t1.id=e.dept_id
// left join t_employee_human h on h.eid=e.id "
        DataTable dt = new FL.DAL.DbSql().ExecuteQuery(@"select t1.id,t1.long_name long_name, t1.parent_id parent_id,
        (case when t2.id is null then 0 else 1 end) as p
        from  t_base_department t1 left join t_base_department t2 on t1.parent_id=t2.id");
        DataTable dt1 = dt;
        for (int i = 0; i < dt.Rows.Count; i++)
        {
        if (dt.Rows[i]["p"].ToString() == "0")
        {

        %>
        <div class="tree1">
            <img src="../images/jian.gif" width="7" />&nbsp;<%=dt.Rows[i]["long_name"] %>
        </div>
        <ul class="tree2" hide="0">
            <%
            for (int j = 0; j < dt1.Rows.Count;j++ )
            {
            if(dt.Rows[i]["id"].ToString()==dt1.Rows[j]["parent_id"].ToString())
            {
            %>

            <li>
                <img src="../images/jian.gif" width="5" />&nbsp;<%=dt1.Rows[j]["long_name"] %>
            </li>
            <div class="tree3" hide="0">
                <div>
                    <a href="#"><img src="../images/user.gif" />张三</a>
                </div>
                <div>
                    <a href="#"><img src="../images/user_female.gif" />李四</a>

                </div>
            </div>
            <%    }
            }
            %>

        </ul>


        <%
        }

        }
        %>
    </div>
</body>
</html>
